﻿//Tên form : Danh sách người dùng
//Người thực hiện: Huypvt - Ngày tạo : 06-02-05
//Mô tả: - Liệt kê danh sách người dùng của hệ thống
//Mô tả chi tiết các chức năng :
//		-Thêm mới : Mở form thêm mới người dùng
//		-Sửa: Mở form sửa thông tin người dùng
//		-Xóa: Xóa người dùng khỏi hệ thống
//Các yêu cầu ràng buộc : Mọi thông tin thay đổi phải thông báo đến người dùng,
//kiểm tra ràng buộc trước khi lưu vào cơ sở dữ liệu.

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using QLNHK.BLL;
using Infragistics.Win;
using Infragistics.Win.Misc;
using Infragistics.Win.UltraWinGrid;
using QLNHK.Controls;

namespace QLNHK.QUANTRIHETHONG
{
    /// <summary>
    /// Summary description for FrmDanhSachNguoiDung.
    /// </summary>
    public class FrmDanhSachNguoiDung : FrmBase
    {
        #region Variable Members
        private cls_Role ObjRole;
        private Cls_PHANQUYEN_NHOM ObjPhanQuyen = new Cls_PHANQUYEN_NHOM();
        private Cls_NHOM_NGUOIDUNG_CHITIET ObjNhomNguoiDungChiTiet;
        private Cls_NGUOIDUNG ObjNguoiDung;
        //private DataTable dtTenNguoiDung;
        private ValueList vlTenNguoiDung;
        private Infragistics.Win.UltraWinGrid.UltraGrid UGMain;
        private Infragistics.Win.Misc.UltraButton btnThemMoi;
        private Infragistics.Win.Misc.UltraButton btnSua;
        private Infragistics.Win.Misc.UltraButton btnXoa;
        private Infragistics.Win.Misc.UltraButton btnDong;
        private System.Data.DataSet DsNguoiDung;
        private System.Data.DataTable dt_DSNguoiDung;
        private System.Data.DataColumn ID_NguoiDung;
        private System.Data.DataColumn ID_HoSo_NhanSu;
        private System.Data.DataColumn Ten_NguoiDung;
        private System.Data.DataColumn MatKhau;
        private System.Data.DataColumn NgayTao;
        private System.Data.DataColumn TinhTrang;
        private Infragistics.Win.UltraWinEditors.UltraTextEditor txtPassword;
        private System.Windows.Forms.ImageList imgGrid;
        private TD.SandBar.MenuBar menuContext;
        private TD.SandBar.MenuButtonItem mnuThemMoi;
        private TD.SandBar.MenuButtonItem mnuChinhSua;
        private TD.SandBar.MenuButtonItem mnuXoa;
        private TD.SandBar.MenuButtonItem mnuDong;
        private TD.SandBar.MenuBarItem mnuSub;
        private UltraGroupBox ultraGroupBox1;
        private System.ComponentModel.IContainer components;
        #endregion
        #region Constructors
        public FrmDanhSachNguoiDung()
        {
            InitializeComponent();
        }
        #endregion
        #region Dispose
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }
        #endregion

        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmDanhSachNguoiDung));
            Infragistics.Win.Appearance appearance1 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance2 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance3 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance4 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance6 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance7 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance8 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance9 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance10 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance11 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance12 = new Infragistics.Win.Appearance();
            this.btnThemMoi = new Infragistics.Win.Misc.UltraButton();
            this.btnSua = new Infragistics.Win.Misc.UltraButton();
            this.btnXoa = new Infragistics.Win.Misc.UltraButton();
            this.btnDong = new Infragistics.Win.Misc.UltraButton();
            this.UGMain = new Infragistics.Win.UltraWinGrid.UltraGrid();
            this.DsNguoiDung = new System.Data.DataSet();
            this.dt_DSNguoiDung = new System.Data.DataTable();
            this.ID_NguoiDung = new System.Data.DataColumn();
            this.ID_HoSo_NhanSu = new System.Data.DataColumn();
            this.Ten_NguoiDung = new System.Data.DataColumn();
            this.MatKhau = new System.Data.DataColumn();
            this.NgayTao = new System.Data.DataColumn();
            this.TinhTrang = new System.Data.DataColumn();
            this.txtPassword = new Infragistics.Win.UltraWinEditors.UltraTextEditor();
            this.imgGrid = new System.Windows.Forms.ImageList(this.components);
            this.menuContext = new TD.SandBar.MenuBar();
            this.mnuSub = new TD.SandBar.MenuBarItem();
            this.mnuThemMoi = new TD.SandBar.MenuButtonItem();
            this.mnuChinhSua = new TD.SandBar.MenuButtonItem();
            this.mnuXoa = new TD.SandBar.MenuButtonItem();
            this.mnuDong = new TD.SandBar.MenuButtonItem();
            this.ultraGroupBox1 = new Infragistics.Win.Misc.UltraGroupBox();
            ((System.ComponentModel.ISupportInitialize)(this.UGMain)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.DsNguoiDung)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.dt_DSNguoiDung)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.txtPassword)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.ultraGroupBox1)).BeginInit();
            this.ultraGroupBox1.SuspendLayout();
            this.SuspendLayout();
            // 
            // imgList
            // 
            this.imgList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imgList.ImageStream")));
            this.imgList.Images.SetKeyName(0, "");
            this.imgList.Images.SetKeyName(1, "");
            this.imgList.Images.SetKeyName(2, "");
            this.imgList.Images.SetKeyName(3, "");
            this.imgList.Images.SetKeyName(4, "");
            this.imgList.Images.SetKeyName(5, "");
            this.imgList.Images.SetKeyName(6, "");
            this.imgList.Images.SetKeyName(7, "");
            this.imgList.Images.SetKeyName(8, "");
            this.imgList.Images.SetKeyName(9, "");
            this.imgList.Images.SetKeyName(10, "");
            this.imgList.Images.SetKeyName(11, "");
            this.imgList.Images.SetKeyName(12, "");
            this.imgList.Images.SetKeyName(13, "");
            // 
            // btnThemMoi
            // 
            this.btnThemMoi.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            appearance1.Image = ((object)(resources.GetObject("appearance1.Image")));
            this.btnThemMoi.Appearance = appearance1;
            this.btnThemMoi.BackColorInternal = System.Drawing.SystemColors.Control;
            this.btnThemMoi.Location = new System.Drawing.Point(359, 442);
            this.btnThemMoi.Name = "btnThemMoi";
            this.btnThemMoi.Size = new System.Drawing.Size(105, 24);
            this.btnThemMoi.TabIndex = 0;
            this.btnThemMoi.Text = "&Thêm mới";
            this.btnThemMoi.Click += new System.EventHandler(this.BtnEvent_Click);
            // 
            // btnSua
            // 
            this.btnSua.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            appearance2.Image = ((object)(resources.GetObject("appearance2.Image")));
            this.btnSua.Appearance = appearance2;
            this.btnSua.BackColorInternal = System.Drawing.SystemColors.Control;
            this.btnSua.Location = new System.Drawing.Point(470, 442);
            this.btnSua.Name = "btnSua";
            this.btnSua.Size = new System.Drawing.Size(96, 24);
            this.btnSua.TabIndex = 1;
            this.btnSua.Text = "&Sửa";
            this.btnSua.Click += new System.EventHandler(this.BtnEvent_Click);
            // 
            // btnXoa
            // 
            this.btnXoa.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            appearance3.Image = ((object)(resources.GetObject("appearance3.Image")));
            this.btnXoa.Appearance = appearance3;
            this.btnXoa.BackColorInternal = System.Drawing.SystemColors.Control;
            this.btnXoa.Location = new System.Drawing.Point(572, 442);
            this.btnXoa.Name = "btnXoa";
            this.btnXoa.Size = new System.Drawing.Size(95, 24);
            this.btnXoa.TabIndex = 2;
            this.btnXoa.Text = "&Xóa";
            this.btnXoa.Click += new System.EventHandler(this.BtnEvent_Click);
            // 
            // btnDong
            // 
            this.btnDong.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            appearance4.Image = ((object)(resources.GetObject("appearance4.Image")));
            this.btnDong.Appearance = appearance4;
            this.btnDong.BackColorInternal = System.Drawing.SystemColors.Control;
            this.btnDong.Location = new System.Drawing.Point(673, 442);
            this.btnDong.Name = "btnDong";
            this.btnDong.Size = new System.Drawing.Size(85, 24);
            this.btnDong.TabIndex = 3;
            this.btnDong.Text = "Đó&ng";
            this.btnDong.Click += new System.EventHandler(this.BtnEvent_Click);
            // 
            // UGMain
            // 
            this.UGMain.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            appearance6.BackColor = System.Drawing.Color.White;
            appearance6.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(33)))), ((int)(((byte)(151)))), ((int)(((byte)(253)))));
            appearance6.BackGradientStyle = Infragistics.Win.GradientStyle.BackwardDiagonal;
            this.UGMain.DisplayLayout.Appearance = appearance6;
            this.UGMain.DisplayLayout.AutoFitStyle = Infragistics.Win.UltraWinGrid.AutoFitStyle.ResizeAllColumns;
            appearance7.FontData.BoldAsString = "True";
            appearance7.TextHAlignAsString = "Left";
            appearance7.TextVAlignAsString = "Middle";
            this.UGMain.DisplayLayout.CaptionAppearance = appearance7;
            this.UGMain.DisplayLayout.CaptionVisible = Infragistics.Win.DefaultableBoolean.True;
            this.UGMain.DisplayLayout.InterBandSpacing = 10;
            this.UGMain.DisplayLayout.Override.AllowDelete = Infragistics.Win.DefaultableBoolean.False;
            this.UGMain.DisplayLayout.Override.AllowGroupBy = Infragistics.Win.DefaultableBoolean.False;
            this.UGMain.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False;
            appearance8.BackColor = System.Drawing.Color.Transparent;
            this.UGMain.DisplayLayout.Override.CardAreaAppearance = appearance8;
            this.UGMain.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect;
            appearance9.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(181)))), ((int)(((byte)(234)))), ((int)(((byte)(253)))));
            appearance9.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(33)))), ((int)(((byte)(151)))), ((int)(((byte)(253)))));
            appearance9.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;
            appearance9.FontData.BoldAsString = "False";
            appearance9.FontData.Name = "Tahoma";
            appearance9.FontData.SizeInPoints = 8F;
            appearance9.ForeColor = System.Drawing.Color.Black;
            appearance9.ThemedElementAlpha = Infragistics.Win.Alpha.Transparent;
            this.UGMain.DisplayLayout.Override.HeaderAppearance = appearance9;
            this.UGMain.DisplayLayout.Override.HeaderClickAction = Infragistics.Win.UltraWinGrid.HeaderClickAction.SortMulti;
            appearance10.BorderColor = System.Drawing.Color.DodgerBlue;
            this.UGMain.DisplayLayout.Override.RowAppearance = appearance10;
            appearance11.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(181)))), ((int)(((byte)(234)))), ((int)(((byte)(253)))));
            appearance11.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(33)))), ((int)(((byte)(151)))), ((int)(((byte)(253)))));
            appearance11.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;
            this.UGMain.DisplayLayout.Override.RowSelectorAppearance = appearance11;
            this.UGMain.DisplayLayout.Override.RowSelectorHeaderStyle = Infragistics.Win.UltraWinGrid.RowSelectorHeaderStyle.SeparateElement;
            this.UGMain.DisplayLayout.Override.RowSelectorNumberStyle = Infragistics.Win.UltraWinGrid.RowSelectorNumberStyle.VisibleIndex;
            this.UGMain.DisplayLayout.Override.RowSelectors = Infragistics.Win.DefaultableBoolean.True;
            this.UGMain.DisplayLayout.Override.RowSpacingBefore = 2;
            appearance12.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(181)))), ((int)(((byte)(234)))), ((int)(((byte)(253)))));
            appearance12.BackColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(33)))), ((int)(((byte)(151)))), ((int)(((byte)(253)))));
            appearance12.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;
            appearance12.ForeColor = System.Drawing.Color.Black;
            this.UGMain.DisplayLayout.Override.SelectedRowAppearance = appearance12;
            this.UGMain.DisplayLayout.RowConnectorColor = System.Drawing.Color.FromArgb(((int)(((byte)(33)))), ((int)(((byte)(151)))), ((int)(((byte)(253)))));
            this.UGMain.DisplayLayout.RowConnectorStyle = Infragistics.Win.UltraWinGrid.RowConnectorStyle.None;
            this.UGMain.Location = new System.Drawing.Point(19, 17);
            this.UGMain.Name = "UGMain";
            this.menuContext.SetSandBarMenu(this.UGMain, this.mnuSub);
            this.UGMain.Size = new System.Drawing.Size(739, 419);
            this.UGMain.TabIndex = 0;
            this.UGMain.InitializeLayout += new Infragistics.Win.UltraWinGrid.InitializeLayoutEventHandler(this.UGMain_InitializeLayout);
            this.UGMain.BeforeRowsDeleted += new Infragistics.Win.UltraWinGrid.BeforeRowsDeletedEventHandler(this.UGMain_BeforeRowsDeleted);
            this.UGMain.DoubleClickRow += new Infragistics.Win.UltraWinGrid.DoubleClickRowEventHandler(this.UGMain_DoubleClickRow);
            this.UGMain.KeyDown += new System.Windows.Forms.KeyEventHandler(this.UGMain_KeyDown);
            // 
            // DsNguoiDung
            // 
            this.DsNguoiDung.DataSetName = "DsNguoiDung";
            this.DsNguoiDung.Locale = new System.Globalization.CultureInfo("en-US");
            this.DsNguoiDung.Tables.AddRange(new System.Data.DataTable[] {
            this.dt_DSNguoiDung});
            // 
            // dt_DSNguoiDung
            // 
            this.dt_DSNguoiDung.Columns.AddRange(new System.Data.DataColumn[] {
            this.ID_NguoiDung,
            this.ID_HoSo_NhanSu,
            this.Ten_NguoiDung,
            this.MatKhau,
            this.NgayTao,
            this.TinhTrang});
            this.dt_DSNguoiDung.TableName = "tb_NGUOIDUNG";
            // 
            // ID_NguoiDung
            // 
            this.ID_NguoiDung.ColumnName = "ID_NguoiDung";
            this.ID_NguoiDung.DataType = typeof(int);
            // 
            // ID_HoSo_NhanSu
            // 
            this.ID_HoSo_NhanSu.Caption = "ID_HoSo_NhanSu";
            this.ID_HoSo_NhanSu.ColumnName = "ID_HoSo_NhanSu";
            this.ID_HoSo_NhanSu.DataType = typeof(int);
            // 
            // Ten_NguoiDung
            // 
            this.Ten_NguoiDung.Caption = "Tên người dùng";
            this.Ten_NguoiDung.ColumnName = "Ten_NguoiDung";
            // 
            // MatKhau
            // 
            this.MatKhau.Caption = "Mật khẩu";
            this.MatKhau.ColumnName = "MatKhau";
            // 
            // NgayTao
            // 
            this.NgayTao.Caption = "Ngày tạo";
            this.NgayTao.ColumnName = "NgayTao";
            this.NgayTao.DataType = typeof(System.DateTime);
            // 
            // TinhTrang
            // 
            this.TinhTrang.Caption = "Tình trạng";
            this.TinhTrang.ColumnName = "TinhTrang";
            this.TinhTrang.DataType = typeof(bool);
            // 
            // txtPassword
            // 
            this.txtPassword.Location = new System.Drawing.Point(574, 89);
            this.txtPassword.Name = "txtPassword";
            this.txtPassword.PasswordChar = '*';
            this.txtPassword.Size = new System.Drawing.Size(80, 22);
            this.txtPassword.TabIndex = 2;
            this.txtPassword.Text = "ultraTextEditor1";
            // 
            // imgGrid
            // 
            this.imgGrid.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imgGrid.ImageStream")));
            this.imgGrid.TransparentColor = System.Drawing.Color.Transparent;
            this.imgGrid.Images.SetKeyName(0, "user.ico");
            this.imgGrid.Images.SetKeyName(1, "users.ico");
            // 
            // menuContext
            // 
            this.menuContext.Guid = new System.Guid("c98115ef-0586-432f-976d-7e81209d281b");
            this.menuContext.ImageList = this.imgList;
            this.menuContext.Items.AddRange(new TD.SandBar.ToolbarItemBase[] {
            this.mnuSub});
            this.menuContext.Location = new System.Drawing.Point(0, 0);
            this.menuContext.Name = "menuContext";
            this.menuContext.OwnerForm = this;
            this.menuContext.Size = new System.Drawing.Size(616, 25);
            this.menuContext.TabIndex = 3;
            this.menuContext.Text = "menuBar1";
            this.menuContext.Visible = false;
            // 
            // mnuSub
            // 
            this.mnuSub.Items.AddRange(new TD.SandBar.ToolbarItemBase[] {
            this.mnuThemMoi,
            this.mnuChinhSua,
            this.mnuXoa,
            this.mnuDong});
            this.mnuSub.Text = "Cây thư mục";
            // 
            // mnuThemMoi
            // 
            this.mnuThemMoi.Icon = ((System.Drawing.Icon)(resources.GetObject("mnuThemMoi.Icon")));
            this.mnuThemMoi.ImageIndex = 0;
            this.mnuThemMoi.Text = "Thêm mới";
            this.mnuThemMoi.Activate += new System.EventHandler(this.mnuThemMoi_Activate);
            // 
            // mnuChinhSua
            // 
            this.mnuChinhSua.Icon = ((System.Drawing.Icon)(resources.GetObject("mnuChinhSua.Icon")));
            this.mnuChinhSua.ImageIndex = 1;
            this.mnuChinhSua.Text = "Chỉnh sửa";
            this.mnuChinhSua.Activate += new System.EventHandler(this.mnuChinhSua_Activate);
            // 
            // mnuXoa
            // 
            this.mnuXoa.Icon = ((System.Drawing.Icon)(resources.GetObject("mnuXoa.Icon")));
            this.mnuXoa.ImageIndex = 2;
            this.mnuXoa.Text = "Xóa";
            this.mnuXoa.Activate += new System.EventHandler(this.mnuXoa_Activate);
            // 
            // mnuDong
            // 
            this.mnuDong.ImageIndex = 8;
            this.mnuDong.Text = "Đóng";
            this.mnuDong.Activate += new System.EventHandler(this.mnuDong_Activate);
            // 
            // ultraGroupBox1
            // 
            this.ultraGroupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.ultraGroupBox1.Controls.Add(this.UGMain);
            this.ultraGroupBox1.Controls.Add(this.btnThemMoi);
            this.ultraGroupBox1.Controls.Add(this.btnDong);
            this.ultraGroupBox1.Controls.Add(this.btnSua);
            this.ultraGroupBox1.Controls.Add(this.btnXoa);
            this.ultraGroupBox1.Location = new System.Drawing.Point(-7, -5);
            this.ultraGroupBox1.Name = "ultraGroupBox1";
            this.ultraGroupBox1.Size = new System.Drawing.Size(777, 485);
            this.ultraGroupBox1.TabIndex = 4;
            this.ultraGroupBox1.ViewStyle = Infragistics.Win.Misc.GroupBoxViewStyle.Office2007;
            // 
            // FrmDanhSachNguoiDung
            // 
            this.AcceptButton = this.btnSua;
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
            this.BackColor = System.Drawing.Color.White;
            this.ClientSize = new System.Drawing.Size(763, 473);
            this.Controls.Add(this.ultraGroupBox1);
            this.Controls.Add(this.menuContext);
            this.Controls.Add(this.txtPassword);
            this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.Name = "FrmDanhSachNguoiDung";
            this.Text = "Danh sách người dùng";
            this.Load += new System.EventHandler(this.FrmDanhSachNguoiDung_Load);
            ((System.ComponentModel.ISupportInitialize)(this.UGMain)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.DsNguoiDung)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.dt_DSNguoiDung)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.txtPassword)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.ultraGroupBox1)).EndInit();
            this.ultraGroupBox1.ResumeLayout(false);
            this.ResumeLayout(false);
            this.PerformLayout();

        }
        #endregion

        #region Form Events

        #region FrmDanhSachNguoiDung_Load
        // Author: khanhlq . Date: 2/9/2006.
        // Modifier: khanhlq. Date:  2/9/2006.
        // Liệt kê những gì đã chỉnh sửa:
        /// <summary>
        ///Sự kiện form main load.
        /// </summary>
        /// <param name="sender">Đối tượng của hàm.</param>
        /// <param name="e">Sự kiện khởi tạo cho  .</param>
        private void FrmDanhSachNguoiDung_Load(object sender, System.EventArgs e)
        {
            try
            {
                ObjNguoiDung = new Cls_NGUOIDUNG();
                ObjNhomNguoiDungChiTiet = new Cls_NHOM_NGUOIDUNG_CHITIET();
                DsNguoiDung = ObjNguoiDung.ListByAll();
                if (DsNguoiDung.Tables[0].Rows.Count != 0)
                {
                    UGMain.DataSource = DsNguoiDung.Tables[0];
                }
                else
                {
                    UGMain.CreationFilter = new EmptyGridCreationFilter(QLNHK.BLL.ThongBao.MSG_Warning_FrmDSNguoiDungNull);
                }

                if (this.UGMain.Rows.Count > 0)
                {
                    this.UGMain.ActiveRow = this.UGMain.Rows[0];
                    UGMain.ActiveRow.Selected = true;
                }

                SetAuthenticationOnForm();
            }
            catch (Exception ex) { Logger.LocalLogger.Instance().WriteMessage(ex); }
        }
        #endregion

        #region UGMain_InitializeLayout
        // Author: khanhlq . Date: 2/9/2006.
        // Modifier: khanhlq. Date:  2/9/2006.
        // Liệt kê những gì đã chỉnh sửa:
        /// <summary>
        /// Handles the InitializeLayout event of the UGMain control.
        /// </summary>
        /// <param name="sender">Đối tượng của hàm.</param>
        /// <param name="e">Sự kiện khởi tạo cho  .</param>

        private void UGMain_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
        {
            UltraGridControls.SetGridStyle(UGMain, AutoFitStyle.ResizeAllColumns, CellClickAction.RowSelect);
            UltraGridBand band = UGMain.DisplayLayout.Bands[0];

            band.Columns["ID_NguoiDung"].Hidden = true;
            band.Columns["ID_HoSo_NhanSu"].Header.Caption = "Tên hồ sơ nhân sự";
            band.Columns["Ten_NguoiDung"].Header.Caption = "Tên đăng nhập";
            band.Columns["Ten_NguoiDung"].CellAppearance.Image = imgGrid.Images[0];
            band.Columns["MatKhau"].Hidden = true;
            band.Columns["IsAdministrator"].Hidden = true;
            band.Columns["MatKhau"].EditorControl = this.txtPassword;
            band.Columns["NgayTao"].Header.Caption = "Ngày tạo";
            band.Columns["NgayTao"].Header.Caption = "Ngày tạo";
            band.Columns["NgayTao"].MaskInput = "{LOC}" + Global.DATE_FORMAT.ToLower();
            band.Columns["TinhTrang"].Header.Caption = "Tình trạng";
            band.Columns["ID_HoSo_NhanSu"].Hidden = true;
            band.Columns["ID_HoSo_NhanSu"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Default;
            band.Columns["ID_HoSo_NhanSu"].ValueList = this.GetTenNguoiDungValueList();
        }
        #endregion

        #region BtnEvent_Click
        // Author: khanhlq . Date: 2/9/2006.
        // Modifier: khanhlq. Date:  2/9/2006.
        // Liệt kê những gì đã chỉnh sửa:
        /// <summary>
        /// Các sự kiện của button thêm mới, sửa, xóa 
        /// Khi click vào các button sẽ hiển thị form dạng dialog
        /// </summary>
        /// <param name="sender">Đối tượng của hàm.</param>
        /// <param name="e">Sự kiện khởi tạo cho  .</param>
        private void BtnEvent_Click(object sender, System.EventArgs e)
        {
            UltraButton btn = (UltraButton)(sender);
            switch (btn.Name)
            {
                case "btnThemMoi":
                    FormSuaOrThem("Them");
                    break;
                case "btnSua":
                    FormSuaOrThem("Sua");
                    break;
                case "btnXoa":
                    DeleteMultiRow();
                    break;
                case "btnDong":
                    this.Close();
                    break;
            }
        }
        #endregion

        #region UGMain_BeforeRowsDeleted
        // Author: khanhlq . Date: 2/14/2006.
        // Modifier: khanhlq. Date:  2/14/2006.
        // Liệt kê những gì đã chỉnh sửa:
        /// <summary>
        /// Handles the BeforeRowsDeleted event of the UGMain control.
        /// </summary>
        /// <param name="sender">Đối tượng của hàm.</param>
        /// <param name="e">Sự kiện khởi tạo cho  .</param>

        private void UGMain_BeforeRowsDeleted(object sender, Infragistics.Win.UltraWinGrid.BeforeRowsDeletedEventArgs e)
        {
            e.DisplayPromptMsg = false;
            if (this.DialogResult == DialogResult.No)
                e.Cancel = true;
        }
        #endregion
        #region UGMain_KeyDown
        private void UGMain_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Delete)
            {
                if (UGMain.ActiveRow != null)
                {
                    if (frmMain.ObjNguoiDung.IsAdministrator || ObjRole.Xoa)
                        DeleteMultiRow();
                    else
                        MessageBox.Show("Không có quyền xóa.", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);

                }
            }
        }
        #endregion
        #region UGMain_DoubleClickRow

        // Author: khanhlq . Date: 2/14/2006.
        // Modifier: khanhlq. Date:  2/14/2006.
        // Liệt kê những gì đã chỉnh sửa:
        /// <summary>
        /// Handles the DoubleClickRow event of the UGMain control.
        /// </summary>
        /// <param name="sender">Đối tượng của hàm.</param>
        /// <param name="e">Sự kiện khởi tạo cho  .</param>

        private void UGMain_DoubleClickRow(object sender, Infragistics.Win.UltraWinGrid.DoubleClickRowEventArgs e)
        {
            if (frmMain.ObjNguoiDung.IsAdministrator || ObjRole.Sua)
                FormSuaOrThem("Sua");
            else
                MessageBox.Show("Không có quyền sửa.", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);

        }
        #endregion
        #region Event ContextMenu
        private void mnuThemMoi_Activate(object sender, System.EventArgs e)
        {
            if (frmMain.ObjNguoiDung.IsAdministrator || ObjRole.Them)
                FormSuaOrThem("Them");
        }
        private void mnuChinhSua_Activate(object sender, System.EventArgs e)
        {
            if (frmMain.ObjNguoiDung.IsAdministrator || ObjRole.Sua)
                FormSuaOrThem("Sua");
            else
                MessageBox.Show("Không có quyền sửa.", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);

        }
        private void mnuXoa_Activate(object sender, System.EventArgs e)
        {
            if (frmMain.ObjNguoiDung.IsAdministrator || ObjRole.Xoa)
                DeleteMultiRow();
            else
                MessageBox.Show("Không có quyền xóa.", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);

        }
        private void mnuDong_Activate(object sender, System.EventArgs e)
        {
            this.Close();
        }
        #endregion
        #endregion

        #region Private Methods
        #region FormSuaOrThem
        // Author: khanhlq . Date: 2/11/2006.
        // Modifier: khanhlq. Date:  2/11/2006.
        // Liệt kê những gì đã chỉnh sửa:
        /// <summary>
        /// Gọi form thêm hay sửa người dùng.
        /// </summary>
        private void FormSuaOrThem(string strChoose)
        {
            switch (strChoose)
            {
                case "Them":
                    FrmTaoNguoiDung frmTaoNguoDungDialog = new FrmTaoNguoiDung();
                    //biến intSuaHayThem để xác định form hiển thị là form thêm
                    //người dùng
                    frmTaoNguoDungDialog.intSuaHayThem = 0;
                    DialogResult dlResult = frmTaoNguoDungDialog.ShowDialog();
                    if (dlResult == DialogResult.OK)
                    {
                        InitObjectClass();
                        this.UGMain.ActiveRow = this.UGMain.Rows[this.UGMain.Rows.Count - 1];
                        UGMain.ActiveRow.Selected = true;
                        UGMain.Focus();
                    }
                    break;
                case "Sua":
                    int intIndexGrid = UGMain.ActiveRow.VisibleIndex;
                    FrmTaoNguoiDung frmSuaNguoDungDialog = new FrmTaoNguoiDung();
                    //biến intSuaHayThem để xác định form hiển thị là form sửa
                    //người dùng
                    frmSuaNguoDungDialog.intSuaHayThem = 1;
                    //string strDecryptMatKhau =  QLNHK.HETHONG.Global.Decrypt(UGMain.ActiveRow.Cells["MatKhau"].Value.ToString());
                    // gán giá trị vào các control form tạo người dùng.
                    frmSuaNguoDungDialog.cboHoSoNhanSu.Value = UGMain.ActiveRow.Cells["ID_HoSo_NhanSu"].Value;
                    frmSuaNguoDungDialog.cboHoSoNhanSu.Enabled = false;
                    frmSuaNguoDungDialog.cboHoSoNhanSu.ValueChanged += new System.EventHandler(frmSuaNguoDungDialog.All_ValueChanged);
                    frmSuaNguoDungDialog.txtNguoiDung.Text = UGMain.ActiveRow.Cells["Ten_NguoiDung"].Value.ToString();
                    frmSuaNguoDungDialog.txtNguoiDung.ValueChanged += new System.EventHandler(frmSuaNguoDungDialog.All_ValueChanged);
                    //frmSuaNguoDungDialog.txtMatKhau.Text = UGMain.ActiveRow.Cells["MatKhau"].Value.ToString();
                    frmSuaNguoDungDialog.txtMatKhau.ValueChanged += new System.EventHandler(frmSuaNguoDungDialog.All_ValueChanged);
                    //frmSuaNguoDungDialog.txtXacNhanMatKhau.Text = UGMain.ActiveRow.Cells["MatKhau"].Value.ToString();
                    frmSuaNguoDungDialog.txtXacNhanMatKhau.ValueChanged += new System.EventHandler(frmSuaNguoDungDialog.All_ValueChanged);
                    frmSuaNguoDungDialog.chkKichHoat.Checked = (bool)UGMain.ActiveRow.Cells["TinhTrang"].Value;
                    frmSuaNguoDungDialog.chkKichHoat.CheckedChanged += new System.EventHandler(frmSuaNguoDungDialog.All_ValueChanged);
                    frmSuaNguoDungDialog.intID_NguoiDung = (int)UGMain.ActiveRow.Cells["ID_NguoiDung"].Value;
                    if (frmSuaNguoDungDialog.ShowDialog() == DialogResult.OK)
                    {
                        InitObjectClass();
                        UGMain.ActiveRow = UGMain.Rows[intIndexGrid];
                        UGMain.ActiveRow.Selected = true;
                        UGMain.Focus();
                    }
                    break;
            }

        }
        #endregion
        #region InitObjectClass
        // Author: khanhlq . Date: 2/11/2006.
        // Modifier: khanhlq. Date:  2/11/2006.
        // Liệt kê những gì đã chỉnh sửa:
        /// <summary>
        /// Hiển thị tất cả các người dùng có trong hệ thống.
        /// nếu không có người nào thì sẽ xóa Grid.
        /// </summary>
        private void InitObjectClass()
        {

            DsNguoiDung = ObjNguoiDung.ListByAll();
            if (DsNguoiDung.Tables[0].Rows.Count != 0)
            {
                UGMain.DataSource = DsNguoiDung.Tables[0];
            }
        }
        #endregion
        #region  thao tác chuyển đổi id_hoso_nhansu thành tên
        // Author: khanhlq . Date: 2/9/2006.
        // Modifier: khanhlq. Date:  2/9/2006.
        // Liệt kê những gì đã chỉnh sửa:
        /// <summary>
        /// Adds the ten nguoi dung value list.
        /// </summary>
        /// <param name="vl">The vl.</param>
        /// <param name="dt">The dt.</param>

        private void AddTenNguoiDungValueList(ValueList vl, DataTable dt)
        {
            foreach (DataRow dr in dt.Rows)
            {
                vl.ValueListItems.Add(dr["ID_HoSo_NhanSu"], dr["Ho_Lot"].ToString() + " " + dr["Ten"].ToString());
            }
        }
        // Author: khanhlq . Date: 2/9/2006.
        // Modifier: khanhlq. Date:  2/9/2006.
        // Liệt kê những gì đã chỉnh sửa:
        /// <summary>
        /// Gets the ten nguoi dung value list.
        /// </summary>
        /// <returns></returns>
        private ValueList GetTenNguoiDungValueList()
        {
            vlTenNguoiDung = new ValueList();
            //this.AddTenNguoiDungValueList(vlTenNguoiDung, Cls_FrequentlyAccess.getDanhSachNhanSu());
            return vlTenNguoiDung;

        }
        #endregion

        #region DeleteMultiRow
        /// <summary>
        /// Deletes the multi row.
        /// </summary>
        /// Tác giả : Khanhlq Ngày tạo : 2/11/2006
        /// Người sửa : Khanhlq Ngày sửa : 2/11/2006
        private void DeleteMultiRow()
        {
            int t = 0;
            if (DialogResult.Yes == MessageBox.Show(string.Format(QLNHK.BLL.ThongBao.MSG_Warning_FrmDanhSachNguoiDung_DeleteData, UGMain.ActiveRow.Cells["Ten_NguoiDung"].Text), QLNHK.BLL.ThongBao.MSG_Caption_Warning, MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
                int i = 0;
                this.UGMain.ActiveRow.Selected = true;
                while (i < UGMain.Selected.Rows.Count)
                {
                    if (!Convert.ToBoolean(UGMain.Selected.Rows[i].Cells["IsAdministrator"].Value))
                    {
                        if (UGMain.Selected.Rows[i].Cells["Ten_NguoiDung"].Value != DBNull.Value)
                        {
                            int int_idnguoidung = (int)UGMain.Selected.Rows[i].Cells["ID_NguoiDung"].Value;
                            //xem trong danh sách nhóm người chi tiết có bao nhiêu hàng id người dùng
                            int lent = ObjNhomNguoiDungChiTiet.ListByAll().Tables[0].Select("ID_NguoiDung = " + int_idnguoidung).Length;
                            //lặ qua tổng số người dùng đó và xóa nhóm người chi tiết theo id người dùng
                            for (int j = 0; j < lent; j++)
                            {
                                ObjNhomNguoiDungChiTiet.DoDelete(int_idnguoidung);
                            }
                            //xóa người dùng  đó theo id được select trên row
                            ObjNguoiDung.DoDelete((int)UGMain.Selected.Rows[i].Cells["ID_NguoiDung"].Value);
                            UGMain.Selected.Rows[i].Delete(false);
                            t++;
                        }
                    }
                    else
                    {
                        MessageBox.Show(QLNHK.BLL.ThongBao.MSG_Warning_FrmDSNguoiDung_KoChoXoa, QLNHK.BLL.ThongBao.MSG_Caption_Warning, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        t++;
                        i++;
                    }
                }
            }
            else
            {
                this.DialogResult = DialogResult.No;
            }
        }
        #endregion
        private void SetAuthenticationOnForm()
        {
            if (!frmMain.ObjNguoiDung.IsAdministrator)
            {
                ObjRole = new cls_Role(Global.GetRole(ObjPhanQuyen.GetRoleByIDChucNang(frmMain.ObjNguoiDung.ID_NguoiDung, this.Tag.ToString())));
                if (!ObjRole.HienThi)
                {
                    foreach (Control ctl in this.Controls)
                    {
                        ctl.Enabled = false;
                    }
                    btnDong.Enabled = true;
                }
                else
                {
                    btnThemMoi.Enabled = ObjRole.Them;
                    btnSua.Enabled = ObjRole.Sua;
                    btnXoa.Enabled = ObjRole.Xoa;
                    mnuChinhSua.Enabled = ObjRole.Sua;
                    mnuThemMoi.Enabled = ObjRole.Them;
                    mnuXoa.Enabled = ObjRole.Xoa;

                    //UGMain.DisplayLayout.Bands[0].Override.AllowDelete = GetStatus(ObjRole.Xoa);
                }
            }

        }

        #endregion

    }
}
